-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat common: slight code improvement #9
Conversation
@@ -17,6 +17,7 @@ message("Libvhost log verbosity: ${LIBVHOST_LOG_VERBOSITY}") | |||
add_library(vhost-server) | |||
add_compile_definitions(_GNU_SOURCE LOG_VERBOSITY=${LIBVHOST_LOG_VERBOSITY}) | |||
target_compile_options(vhost-server PRIVATE | |||
-std=gnu17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CMakeLists.txt was introduced by NBS since they integrate libvhost as part of their project, we don't actually build with it locally.
This will need to be checked in with them (might break their build).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is compiled exclusively by gnu extensions of the standard, it is worth explicitly denoting this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aikuchin Would you be okay with this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need 17 here? I was quite sure that 11 was enough, maybe 14, but 17 seems like an overkill and will limit supported compilers significantly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C14 does not exist. C17 is supported by GCC 8.1 and Clang 7. C23 causes confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to understand the motivation for gnu17 if we only use features for gnu11. Why do we need 17, do we ?
If we need new compiler features it is easy to bump requirements in new version, but downgrading standard is always more complicated.
UPD: Since c17 is just a bugfix release for c11 I agree that gnu17 is OK here.
And should we also add required standard version to meson.build?
@@ -61,3 +62,6 @@ target_sources(vhost-server PRIVATE | |||
virtio/virtio_blk.c | |||
virtio/virtio_fs.c | |||
) | |||
|
|||
|
|||
add_subdirectory(tests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I'm not sure NBS needs the tests subdirectory for their integration (and this might break their isolated build as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is very unusual to be selective about build systems and focus on only one consumer for an open source project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building tests makes sense and NBS will fix their build if building tests break it. So I think this is a good idea to build tests.
Can you please clean up the history to make commits atomic and have a description of why/how they improve the code? Ideally i'd want something like this: Commit 1:
Commit 2:
Commit N... |
01559c4
to
aed2710
Compare
aed2710
to
b4abebc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I have some NITs but no strong objections.
@@ -17,6 +17,7 @@ message("Libvhost log verbosity: ${LIBVHOST_LOG_VERBOSITY}") | |||
add_library(vhost-server) | |||
add_compile_definitions(_GNU_SOURCE LOG_VERBOSITY=${LIBVHOST_LOG_VERBOSITY}) | |||
target_compile_options(vhost-server PRIVATE | |||
-std=gnu17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to understand the motivation for gnu17 if we only use features for gnu11. Why do we need 17, do we ?
If we need new compiler features it is easy to bump requirements in new version, but downgrading standard is always more complicated.
UPD: Since c17 is just a bugfix release for c11 I agree that gnu17 is OK here.
And should we also add required standard version to meson.build?
@@ -61,3 +62,6 @@ target_sources(vhost-server PRIVATE | |||
virtio/virtio_blk.c | |||
virtio/virtio_fs.c | |||
) | |||
|
|||
|
|||
add_subdirectory(tests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building tests makes sense and NBS will fix their build if building tests break it. So I think this is a good idea to build tests.
To check when modifying code when using сmake, it is worth collecting all binary files. The code is compiled only with gnu extensions of the standard. This should be explicitly stated. Signed-off-by: Aleksandr Golubev <[email protected]>
The test logging contains a call to a not-thread-save method localtime. Signed-off-by: Aleksandr Golubev <[email protected]>
The results of calls to methods write() and read() are now checked in the debug build, which will help diagnose potential problems. Signed-off-by: Aleksandr Golubev <[email protected]>
b4abebc
to
2cee9b2
Compare
No description provided.